import { createApp, createVNode } from "vue";
import App from "./App.vue";
import pinia from "@/store";
import router from "./router";
import * as Icons from "@element-plus/icons-vue";
import "element-plus/theme-chalk/el-loading.css";
import "../src/assets/css/main.scss";
import { vLoading } from "element-plus/es/components/loading/src/directive";
import directives from "./directives";
import '../node_modules/nprogress/nprogress.css'
// import { mockFn } from "./mock/index";
// 会影响element-plus的el-upload上传功能 不用时请关闭
// mockFn();
// 移动端适配
(function (doc, win) {
  const resizeEvent = "orientationchange" in window ? "orientationchange" : "resize";
  let recalCulate = function () {
    let docEle = document.documentElement || document.body,
      w = docEle.clientWidth,
      num = (w > 750 ? 750 : w) / 750;
    docEle.style.fontSize = (num * 100).toFixed(1) + "px";
  };
  recalCulate();
  if (!doc.addEventListener) return;
  win.addEventListener(resizeEvent, recalCulate, false);
})(document, window);
const app = createApp(App);
const Icon = (props: { icon: string }) => {
  const { icon } = props;
  return createVNode(Icons[icon as keyof typeof Icons]);
};
app.component("Icon", Icon);
app.directive("loading", vLoading);
app.use(directives).use(router).use(pinia).mount("#app");
